package sistema.controleVendas.persistencia;

import java.util.List;

import javax.persistence.EntityManager;

import sistema.controleVendas.entidades.Itens;

public class GerenciarItemPersistencia {
	EntityManager em = Conexao.contectar();
	public Itens adicionarItem(Itens item){
		em.getTransaction().begin();
		em.persist(item);
		em.getTransaction().commit();
		return item;
	}
	public void removerItem(Itens item){
		em.getTransaction().begin();
		em.persist(item);
		em.getTransaction().commit();
	}
	public Itens buscarItem(Itens item){
		return (Itens)em.createQuery("Select i From Itens i Where i.id=:param")
		.setParameter("param", item.getId()).getSingleResult();
	}
	public List<Itens> listarItens(){
		return em.createQuery("Select i From Itens i ")
		.getResultList();
	}

}
